// pages/region/classList/index.js
var basePage=require('../../../common/BasePage')
var baseList=require('../../../common/BaseList')
Page({
behaviors:[basePage,baseList],

    /**
     * 页面的初始数据
     */
    data: {
        reqUrl: '/home/areaWarehouse/getWarehousePriceSize',
        wh_id:0,
        cateInfo: {},
        whIndex: 0,
        showInterval: false,
        manage_add_min_price: "",
        manage_add_max_price: ''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.setData({
            wh_id:options.whId
        })
        this.data.reqData.wh_id=options.whId
        this.req_items()
    },
    setInterval(e) {
        let item = e.currentTarget.dataset.item;
        let index = e.currentTarget.dataset.index;
        this.setData({
            showInterval: true,
            cateInfo: item,
            whIndex: index,
            manage_add_min_price: "",
            manage_add_max_price: ""
        })
    },
    submit() {
        var {
            cateInfo,
            whIndex,
            itemArr,
            manage_add_min_price,
            manage_add_max_price
        } = this.data
        if (!manage_add_min_price) {
            wx.showToast({
                title: '请输入最低涨跌价格',
                icon: "none"
            })
            return
        }
        if (!manage_add_max_price) {
            wx.showToast({
                title: '请输入最高涨跌价格',
                icon: "none"
            })
            return
        }
        this.request({
            url: this.data.host + "/home/areaWarehouse/setWarehousePriceSize",
            data: {
                wh_id: this.data.wh_id,
                cate_id:cateInfo.cate_id,
                manage_add_min_price: manage_add_min_price,
                manage_add_max_price: manage_add_max_price
            },
            loadingTip: "提交中···",
            method: "POST"
        }, res => {
            itemArr[whIndex].wh_min_price = manage_add_min_price
            itemArr[whIndex].wh_max_price = manage_add_max_price
            this.setData({
                showInterval: false,
                itemArr: itemArr
            })
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

})